/** Author: David Powell
This file produces Figure A4
**/


clear all
set more off

set seed 8721

global dir "/jules/b/dpowell"
global DATA "${dir}/purdue/replication/DATA"
global OUTPUT "${dir}/purdue/replication/output"




use ${DATA}/finaldata


**convert to MEDs
gen oxycontin_rate=1.5*1000*oxycontin/(60*totpop) if year>1999 & year<2017
gen oxycodone_rate=1.5*1000*oxycodone/(60*totpop)
gen hydrocodone_rate=1000*hydrocodone/(60*totpop)

keep if year>=1996

gen mc_oxy=1000*oxycontin_SDUD/medicaidb
replace mc_oxy=mc_oxy*4/numobs

gen tripl=(nontripl==0)
preserve
set scheme s2color  
keep if year==2000
separate oxycontin_rate, by(tripl==1)

label def stf 6 California 4 Arizona 41 Oregon 32 Nevada 1 Alabama 5 Arkansas 8 Colorado 2 Alaska 9 Connecticut 10 Delaware 11 D.C. 12 Florida 13 Georgia 15 Hawaii 16 Idaho 17 Illinois 18 Indiana 19 Iowa 20 Kansas 21 Kentucky 22 Louisiana 23 Maine 24 Maryland 25 Massachusetts 26 Michigan 27 Minnesota 28 Mississippi 29 Missouri 30 Montana 31 Nebraska 33 "New Hampshire" 34 "New Jersey" 35 "New Mexico" 36 "New York" 37 "North Carolina" 38 "North Dakota" 39 Ohio 40 Oklahoma 41 Oregon 42 Pennsylvania 44 "Rhode Island" 45 "South Carolina" 46 "South Dakota" 47 Tennessee 48 Texas 49 Utah 50 Vermont 51 Virginia 53 Washington 54 "West Virginia" 55 Wisconsin 56 Wyoming

label val stf stf

graph bar oxycontin_rate0 oxycontin_rate1 , ylabel(,nogrid) graphregion(color(white))   nofill over(stf, sort(oxycontin_rate) label(angle(90) labsize(vsmall)   ) ) bar(1, bfcolor(none))   ytitle("Per Capita Morphine Equivalent Doses" ,  axis(1))  legend(off)
gr export ${OUTPUT}/figA4b.eps, replace

restore



set scheme s2color  
keep if year==1996
drop if stf==47 | stf==4
separate mc_oxy, by(tripl==1)

label def stf 6 California 4 Arizona 41 Oregon 32 Nevada 1 Alabama 5 Arkansas 8 Colorado 2 Alaska 9 Connecticut 10 Delaware 11 D.C. 12 Florida 13 Georgia 15 Hawaii 16 Idaho 17 Illinois 18 Indiana 19 Iowa 20 Kansas 21 Kentucky 22 Louisiana 23 Maine 24 Maryland 25 Massachusetts 26 Michigan 27 Minnesota 28 Mississippi 29 Missouri 30 Montana 31 Nebraska 33 "New Hampshire" 34 "New Jersey" 35 "New Mexico" 36 "New York" 37 "North Carolina" 38 "North Dakota" 39 Ohio 40 Oklahoma 41 Oregon 42 Pennsylvania 44 "Rhode Island" 45 "South Carolina" 46 "South Dakota" 47 Tennessee 48 Texas 49 Utah 50 Vermont 51 Virginia 53 Washington 54 "West Virginia" 55 Wisconsin 56 Wyoming

label val stf stf

graph bar mc_oxy0 mc_oxy1 , ylabel(,nogrid) graphregion(color(white))   nofill over(stf, sort(mc_oxy) label(angle(90) labsize(vsmall)   ) ) bar(1, bfcolor(none))   ytitle("Medicaid Prescriptions per 1,000 Benes" ,  axis(1))  legend(off)
gr export ${OUTPUT}/figA4a.eps, replace
